/*
	PROG: toyshop
	LANG: C++
	ID: luiza1
*/

#include <stdio.h>
using namespace std;

typedef struct toy {
	int i;
	double coef;
} Toy;

int cases;
int n;
int toys[25000][2];
Toy buys[3];

int cmp(double a, double b, double EPS=1e-15) {
	if ((a-b)>EPS) return 1;
	else if ((b-a)<EPS) return -1;

	return 0;
}

int main() {
//	scanf("%d", &cases);

	freopen("toyshop.in", "r", stdin);
	freopen("toyshop.out", "w", stdout);

//	while (cases--) {
		scanf("%d", &n);

		for (int i=0; i<n; i++)
			scanf("%d %d", &toys[i][0], &toys[i][1]);
	
		for (int i=0; i<3; i++) {
			buys[i].coef=-1.00;
		}
	
		for (int i=0; i<n; i++) {
			Toy temp;
			temp.i=i;

			temp.coef = (double)toys[i][0]/(double)toys[i][1];

			//printf("%d %lf\n", temp.i, temp.coef);

			for (int j=0; j<3; j++) {
				Toy aux;

				if (cmp(temp.coef, buys[j].coef)==1) {
					aux.i=buys[j].i;
					aux.coef=buys[j].coef;

					buys[j].coef=temp.coef;
					buys[j].i=temp.i;

					if (j<2) {
						temp.coef=buys[j+1].coef;
						temp.i=buys[j+1].i;

						buys[j+1].coef = aux.coef;
						buys[j+1].i = aux.i;

						if (j<1) {
							buys[j+2].i=temp.i;
							buys[j+2].coef=temp.coef;
						}
					}

					break;
				}				
			}

		}


		int sum=0;

		for (int i=0; i<3; i++)
			sum+=toys[buys[i].i][1];

		printf("%d\n", sum);

		for (int i=0; i<3; i++)
			printf("%d\n", buys[i].i+1);
//	}

	return 0;
}
